package ReserveController;

import java.util.HashMap;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

import Dao.ReserveDao;

public class Reservethanks implements Controller{

	private ReserveDao reserveDao;
	
	public void setReserveDao(ReserveDao reserveDao) {
		this.reserveDao = reserveDao;
	}
	
	@Override
	public ModelAndView handleRequest(HttpServletRequest arg0,
			HttpServletResponse arg1) throws Exception {

		String RV_START = "";
		if(arg0.getParameter("RV_START")!=null){
			RV_START = arg0.getParameter("RV_START");
		};
		String RV_END = "";
		if(arg0.getParameter("RV_END")!=null){
			RV_END = arg0.getParameter("RV_END");
		};
		String RV_DAY = "";
		if(arg0.getParameter("RV_DAY")!=null){
			RV_DAY = arg0.getParameter("RV_DAY");
		};
		String RV_ROOM = "";
		if(arg0.getParameter("RV_ROOM")!=null){
			RV_ROOM = arg0.getParameter("RV_ROOM");
		};
		String RV_PEOPLE = "";
		if(arg0.getParameter("RV_PEOPLE")!=null){
			RV_PEOPLE = arg0.getParameter("RV_PEOPLE");
		};
		String RV_ROOMPRICE = "";
		if(arg0.getParameter("RV_ROOMPRICE")!=null){
			RV_ROOMPRICE = arg0.getParameter("RV_ROOMPRICE");
		};
		String RV_PEOPLEPRICE = "";
		if(arg0.getParameter("RV_PEOPLEPRICE")!=null){
			RV_PEOPLEPRICE = arg0.getParameter("RV_PEOPLEPRICE");
		};
		String RV_PRICE = "";
		if(arg0.getParameter("RV_PRICE")!=null){
			RV_PRICE = arg0.getParameter("RV_PRICE");
		};
		String RV_NAME = "";
		if(arg0.getParameter("RV_NAME")!=null){
			RV_NAME = arg0.getParameter("RV_NAME");
		};
		String RV_TEL = "";
		if(arg0.getParameter("RV_TEL")!=null){
			RV_TEL = arg0.getParameter("RV_TEL");
		};
		String RV_PHONE = "";
		if(arg0.getParameter("RV_PHONE")!=null){
			RV_PHONE = arg0.getParameter("RV_PHONE");
		};
		String RV_MAIL = "";
		if(arg0.getParameter("RV_MAIL")!=null){
			RV_MAIL = arg0.getParameter("RV_MAIL");
		};
		String RV_ADDR = "";
		if(arg0.getParameter("RV_ADDR")!=null){
			RV_ADDR = arg0.getParameter("RV_ADDR");
		};
		String RV_NOTE = "";
		if(arg0.getParameter("RV_NOTE")!=null){
			RV_NOTE = arg0.getParameter("RV_NOTE");
		};
		String RV_PAYNAME = "";
		if(arg0.getParameter("payment_name")!=null){
			RV_PAYNAME = arg0.getParameter("payment_name");
		};
		String RV_PAYBANK = "";
		if(arg0.getParameter("payment_bank")!=null){
			RV_PAYBANK = arg0.getParameter("payment_bank");
		};
		String RV_PAYTYPE = "";
		if(arg0.getParameter("payment_type")!=null){
			RV_PAYTYPE = arg0.getParameter("payment_type");
		};
		
		HashMap<String, String> data = new HashMap<>();
		
		data.put("RV_START", RV_START);
		data.put("RV_END", RV_END);
		data.put("RV_DAY", RV_DAY);
		data.put("RV_ROOM", RV_ROOM);
		data.put("RV_NAME", RV_NAME);
		data.put("RV_TEL", RV_TEL);
		data.put("RV_PHONE", RV_PHONE);
		data.put("RV_MAIL", RV_MAIL);
		data.put("RV_ADDR", RV_ADDR);
		data.put("RV_PEOPLE", RV_PEOPLE);
		data.put("RV_ROOMPRICE", RV_ROOMPRICE);
		data.put("RV_PEOPLEPRICE", RV_PEOPLEPRICE);
		data.put("RV_PRICE", RV_PRICE);
		data.put("RV_NOTE", RV_NOTE);
		data.put("RV_PAYNAME", RV_PAYNAME);
		data.put("RV_PAYBANK", RV_PAYBANK);
		data.put("RV_PAYTYPE", RV_PAYTYPE);
		
//		System.out.println(data.get("RV_START"));
//		System.out.println(data.get("RV_END"));
//		System.out.println(data.get("RV_DAY"));
//		System.out.println(data.get("RV_ROOM"));
//		System.out.println(data.get("RV_NAME"));
//		System.out.println(data.get("RV_TEL"));
//		System.out.println(data.get("RV_PHONE"));
//		System.out.println(data.get("RV_MAIL"));
//		System.out.println(data.get("RV_ADDR"));
//		System.out.println(data.get("RV_PEOPLE"));
//		System.out.println(data.get("RV_PRICE"));
//		System.out.println(data.get("RV_NOTE"));
//		System.out.println(data.get("RV_PAYNAME"));
//		System.out.println(data.get("RV_PAYBANK"));
		
		Object list = reserveDao.setReserve(data);
		
		ModelAndView mav = new ModelAndView();
		mav.addObject("list",list);
		mav.setViewName("reservethanks");
		
		return mav;
	}
	
}
